//
//  YSGMyopiaHeaderView.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2021/1/5.
//  Copyright © 2021 QDSG. All rights reserved.
//

import UIKit

class YSGMyopiaHeaderView: UIView {

    private lazy var bannerView = BannerView()
    
    private lazy var buttonView = YSGMyopiaButtonParentView()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    convenience init(with vc: UIViewController?, imageArr: [String] = [], closure: TappedHandle?) {
        self.init()
        backgroundColor = .white
        bannerView.delegate = vc as? BannerViewDelegate
        bannerView.imageUrls = imageArr
        bannerView.isAutoScroll = imageArr.count > 1
        addSubview(bannerView)
        addSubview(buttonView)
        
        buttonView.updateUI(closure: closure)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        bannerView.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(16)
            make.right.equalToSuperview().offset(-16)
            make.top.equalToSuperview()
            make.height.equalTo(100)
        }
        
        buttonView.snp.makeConstraints { (make) in
            make.left.right.bottom.equalToSuperview()
            make.top.equalTo(bannerView.snp.bottom)
        }
    }
}
